package cn.cjxy.springmvcdemo1.controller;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HelloController implements Controller {
    //使用方式和javaweb类似
	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		//  返回的是模型和视图
        ModelAndView modelAndView = new ModelAndView();
        //设置模型  k-v、
        modelAndView.addObject("message", "Hello World");
        //设置视图
        modelAndView.setViewName("/hello.jsp");
        //返回模型和视图
        return modelAndView;
	}
}